//
//  CryptoTest.swift
//  UtilityTests
//
//  Created by yuhus on 2024/7/2.
//

import XCTest
import Nimble
@testable import Utility

final class CryptoTest: XCTestCase {
  
  override func setUpWithError() throws {
    // Put setup code here. This method is called before the invocation of each test method in the class.
  }
  
  override func tearDownWithError() throws {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
  }
  
  func testMD5() throws {
    // 32位小写
    expect(CryptoUtils.MD5("1234567890")).to(equal("e807f1fcf82d132f9bb018ca6738a19f"))
    // 32位大写
    expect(CryptoUtils.MD5("1234567890").uppercased()).to(equal("E807F1FCF82D132F9BB018CA6738A19F"))
    // 16位小写
    expect(CryptoUtils.MD5("1234567890").dropFirst(8).dropLast(8)).to(equal("f82d132f9bb018ca"))
    // 16位大写
    expect(CryptoUtils.MD5("1234567890").dropFirst(8).dropLast(8).uppercased()).to(equal("F82D132F9BB018CA"))
  }
  
  func testSHA256() throws {
    expect(CryptoUtils.SHA256("1234567890")).to(equal("c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646"))
  }
  
  func testAES() throws {
    expect(CryptoUtils.SHA256("1234567890")).to(equal("c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646"))
  }
  
  func testPerformanceExample() throws {
    // This is an example of a performance test case.
    self.measure {
      // Put the code you want to measure the time of here.
    }
  }
  
}
